home *** CD-ROM | disk | FTP | other *** search
- ; James L Boyd's cool WBPaint program :)
-
- ; for gadget creation :
-
- ; To do :
-
- ; Replace WB clearing window at end with appicon, which
- ; clears the screen in a much nicer way ;)
-
- ; hmm...palette...?
-
- Function.w PixelLen{a$}
- rp.l=RastPort(0) ; The rastport of the used window.
- Function Return TextLength_(rp,&a$,Len(a$))
- End Function
-
- WBStartup ; run from icon
-
- FindScreen 0,"Workbench Screen" ; find the WB screen
-
- NoCli
-
- *scr.Screen=Peek.l(Addr Screen(0))
-
- If *scr=0 Then Request "WBPaint","Screen structure failure...","END"
-
- ScreenToFront_ *scr
-
- *scfont.TextAttr=*scr.Screen\Font ; font of the screen
- fh.b=*scfont.TextAttr\ta_YSize ; font height
- fname$=Peek$(*scfont.TextAttr\ta_Name) ; font name
-
- If fh
- LoadFont 0,fname$,fh
- Else Request "WBPaint","Font structure failure...","END"
- EndIf
-
- th.b=*scr\WBorTop+fh+1 ; title bar height
-
- *rp.RastPort=*scr\_RastPort ; the screen's rastport
-
- If *rp=0 Then Request "WBPaint","RastPort structure failure...","END"
-
- Window 0,0,0,1,1,$1006,"WBPaint",1,2 ; our "hidden" window ;)
-
- ;-------------------------------------------
-
- ; heh heh heh :
-
- ; if you want to add more gadgets, just add the name of the
- ; gadget to the DATA ist at the bottom, before the "END" string.
- ; they're numbered automatically...
-
- .SetUpGadgets
-
- gad.b=50 ; starting gadget
-
- While a$<>"END"
- b$=""
- Read a$:b$+" "+a$+" " ; padding spaces
- If a$="END" Then Pop While:Goto skip ; reached end, don't create
- newlen.w=PixelLen{b$} ; gadget width
- GTButton 0,gad,newx.w,0,newlen,th,a$,$10
- newx+PixelLen{b$} ; next gadget's x position
- gad+1 ; increase gadget number
- Wend
-
- skip ; go here after reading "END"
-
- ; widen our window :
-
- SizeWindow_ Peek.l(Addr Window(0)),*scr\WBorLeft+*scr\WBorRight+newx-1,fh*3-1
-
- ;-------------------------------------------
-
- AttachGTList 0,0 ; attach the gadgets
-
- loop ; main loop
-
- e.l=Event ; grab event
-
- VWait ; avoid jerkiness ;)
-
- If Joyb(0)=3 ; both mouse buttons
- Move_ *rp,*scr\_MouseX,*scr\_MouseY ; move to x,y
- Draw_ *rp,*scr\_MouseX,*scr\_MouseY ; draw to same position
- EndIf
-
- Select e ; what was event?
-
- Case $40 ; gadget hit
- Select GadgetHit
- Case 50
- If Request ("WBPaint","Do you really want to quit?!","Yes|No")
- Request "WBPaint","Hacky WB-clearing window coming up!","OK"
- Window 1,0,0,*scr\Width,*scr\Height,0,"",0,0
- End
- EndIf
- Case 51
- Request "WBPaint","WBPaint v0.1 beta||James L Boyd 1999","X"
- Case 52
- Request "WBPaint","WBPaint v0.1 beta||Help requester||Hold left and right buttons, move pointer.","Duh"
- End Select
-
- End Select
-
- Goto loop
-
- strings:
- Data$ "Quit","About","Help","END"
-